package com.yuqing.sentimentapp.yqlist.adapter;

import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;

import com.linkface.baselibrary.utils.CollectionUtils;

import java.util.List;

public class YqReportAdapter extends FragmentPagerAdapter {

    private List<String> mTitles;
    private List<Fragment> mFragmentList;

    public YqReportAdapter(FragmentManager fm) {
        super(fm);
    }

    public YqReportAdapter(FragmentManager fm, List<Fragment> mFragmentList, List<String> mTitles) {
        super(fm);
        this.mTitles = mTitles;
        this.mFragmentList = mFragmentList;
    }

    @Override
    public CharSequence getPageTitle(int position) {
        return !CollectionUtils.isNullOrEmpty(mTitles) ? mTitles.get(position) : "";
    }

    @Override
    public Fragment getItem(int position) {
        return mFragmentList.get(position);
    }

    @Override
    public int getCount() {
        return mTitles.size();
    }

}
